<template>
  <div>
    <el-breadcrumb separator="/">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>商品管理</el-breadcrumb-item>
      <el-breadcrumb-item>添加商品</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 卡片区域 -->
    <el-card>
      <el-input style="width:500px" placeholder="请输入内容" v-model="input3" class="input-with-select">
        <el-button slot="append" icon="el-icon-search"></el-button>
      </el-input>
      <el-table :data="orderList" border stripe>
        <el-table-column type="index" label="#">
        </el-table-column>
        <el-table-column label="订单编号" prop="order_number">
        </el-table-column>
        <el-table-column label="订单价格" prop="order_price">
        </el-table-column>
        <el-table-column label="是否付款" prop="order_pay">
          <template v-slot="{row}">
            <el-tag type="success" v-if="row.order_pay==='1'">已支付</el-tag>
            <el-tag type="danger" v-else>未支付</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="是否发货" prop="is_send">
        </el-table-column>
        <el-table-column label="下单时间" prop="create_time">
          <template v-slot="{row}">
            {{row.create_time | dateFormat}}
          </template>
        </el-table-column>
        <el-table-column label="操作">
          <template>
            <el-button @click="editAdress" type="primary" icon="el-icon-edit" size="mini"></el-button>
            <el-button @click="expressFn" type="warning" icon="el-icon-location" size="mini"></el-button>
          </template>
        </el-table-column>
      </el-table>
      <!-- 修改对话框 -->
      <el-dialog title="修改地址" :visible.sync="editAddressVisible" width="50%">
        <el-form :model="editAdressForm" ref="editAdressFormRef" :rules="editAdressFormRules" label-width="80px"
          :inline="false" size="normal">
          <el-form-item label="省市区/县">
            <el-cascader :options="cityData" v-model="cascaderValue" clearable filterable>
            </el-cascader>
          </el-form-item>
          <el-form-item label="详细地址">
            <el-input></el-input>
          </el-form-item>
        </el-form>
        <span slot="footer">
          <el-button @click="editAddressVisible = false">取消</el-button>
          <el-button type="primary" @click="editAddressVisible=false">确定</el-button>
        </span>
      </el-dialog>
      <!-- 物流信息 -->
      <el-dialog title="物流信息" :visible.sync="expressVisible" width="50%">
        <el-timeline :reverse="true">
          <el-timeline-item v-for="(item, index) in expressList" :key="index" :timestamp="item.time">
            {{item.content}}
          </el-timeline-item>
        </el-timeline>
        <span slot="footer">
          <el-button @click="expressVisible = false">取消</el-button>
          <el-button type="primary" @click="expressVisible=false">确定</el-button>
        </span>
      </el-dialog>

    </el-card>
  </div>
</template>

<script>
import cityData from './citydata.js'
export default {
  data () {
    return {
      editAdressFormRules: {},
      editAdressForm: {},
      input3: '',
      queryInfo: {
        pagenum: 1,
        pagesize: 20
      },
      orderList: [],
      editAddressVisible: false,
      cityData,
      cascaderValue: '',
      expressVisible: false,
      expressList: []
    }
  },
  methods: {
    async expressFn () {
      this.expressVisible = true
      const { data: res } = await this.$http.get('http://localhost:8080/api/express')
      this.expressList = res.data
      console.log(this.expressList)
    },
    editAdress () {
      this.editAddressVisible = true
    },
    async getOrderList () {
      const { data: res } = await this.$http.get('orders', {
        params: this.queryInfo
      })
      if (res.meta.status !== 200) return this.$message.error('获取失败')
      this.orderList = res.data.goods
      console.log(this.orderList)
    }
  },
  computed: {},
  watch: {},
  filters: {},
  components: {},
  async created () {
    this.getOrderList()
    const res = await this.$http.get('http://localhost:8080/api/person')
    console.log(res)
  },
  mounted () { }
}
</script>

<style scoped lang='less'>
</style>
